#include "QtDataModelRegistry.hpp"

#include <QtCore/QFile>
#include <QtWidgets/QMessageBox>

namespace Qt
{
	std::unique_ptr<QtNodeDataModel>
		QtDataModelRegistry::
		create(QString const &modelName)
	{
		auto it = _registeredItemCreators.find(modelName);

		if (it != _registeredItemCreators.end())
		{
			return it->second();
		}

		return nullptr;
	}


	QtDataModelRegistry::RegisteredModelCreatorsMap const &
		QtDataModelRegistry::
		registeredModelCreators() const
	{
		return _registeredItemCreators;
	}


	QtDataModelRegistry::RegisteredModelsCategoryMap const &
		QtDataModelRegistry::
		registeredModelsCategoryAssociation() const
	{
		return _registeredModelsCategory;
	}


	QtDataModelRegistry::CategoriesSet const &
		QtDataModelRegistry::
		categories() const
	{
		return _categories;
	}


	TypeConverter
		QtDataModelRegistry::
		getTypeConverter(NodeDataType const & d1,
			NodeDataType const & d2) const
	{
		TypeConverterId converterId = std::make_pair(d1, d2);

		auto it = _registeredTypeConverters.find(converterId);

		if (it != _registeredTypeConverters.end())
		{
			return it->second;
		}

		return TypeConverter{};
	}
}